<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</head>
<body>
    <button id="btn1">GET请求无参数</button>
    <button id="btn2">GET请求有参数</button>
    <button id="btn3">POST请求无参数</button>
    <button id="btn4">POST请求有参数</button>
    <div id="box">
        
    </div>

    <script>
        let btn1 = document.getElementById("btn1");
        let btn2 = document.getElementById("btn2");
        let btn3 = document.getElementById("btn3");
        let btn4 = document.getElementById("btn4");
        let box = document.getElementById("box");

        btn1.onclick = function(){
            axios({
                url:"https://tools.mgtv100.com/external/v1/pear/kfc",
            })
            .then(res => {
                console.log(res);
                console.log(res.data);
                console.log(res.data.data);
                box.innerText = res.data.data;
            })
        }


        btn2.onclick = function(){
            let text = window.prompt("请输入内容");
            axios({
                url:"https://api.mhimg.cn/api/ATime_txt/",
                method:"get",
                params:{
                    word:text,
                    sort:"紫绶金章",
                    sort2:"小菱心"
                }
            })
            .then(res => {
                let img = document.createElement("img");
                img.src = res.data.zhenbi[0].info[0];
                box.appendChild(img);
            })
        }

        btn4.onclick = function(){
            let money = window.prompt("请输入金额");
            axios({
                url:"https://tools.mgtv100.com/external/v1/pear/alipay",
                method:"post",
                data:{
                    amount:money
                }
            })
            .then(res => {
                let audio = document.createElement("audio");
                audio.src = res.data.data;
                audio.controls = true;
                box.appendChild(audio);
            })
            
        }
    </script>
</body>
</html>